package com.turnengine.client.local.location.command.gwt;

import static com.javabi.common.dependency.DependencyFactory.getDependency;

import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.javabi.codebuilder.generated.gwt.IGeneratedRemoteServiceServlet;
import com.javabi.command.IExecutableCommandResponse;
import com.javabi.command.errorcode.gwt.GwtErrorCodeException;
import com.javabi.command.executor.ICommandExecutorService;
import com.turnengine.client.local.location.bean.ICoordinateGrid;
import com.turnengine.client.local.location.command.GetCoordinateGrids;
import java.util.List;

/**
 * The Get Coordinate Grids Servlet.
 */
public class GetCoordinateGridsServlet extends RemoteServiceServlet implements IGeneratedRemoteServiceServlet, GetCoordinateGridsService {

	public List<ICoordinateGrid> getCoordinateGrids(long loginId, int instanceId) throws GwtErrorCodeException {
		GetCoordinateGrids command = new GetCoordinateGrids(loginId, instanceId);
		ICommandExecutorService service = getDependency(ICommandExecutorService.class);
		IExecutableCommandResponse<List<ICoordinateGrid>> response = service.execute(command);
		if (response.hasErrors()) {
			throw new GwtErrorCodeException(response);
		}
		return response.getReturnValue();
	}
}
